package top.lingkang.listener;

import com.badlogic.gdx.physics.box2d.*;
import top.lingkang.constants.FixtureDefType;
import top.lingkang.screen.PlayScreen;

public class WorldListener implements ContactListener {
    private PlayScreen playScreen;

    public WorldListener(PlayScreen playScreen) {
        this.playScreen = playScreen;
    }

    @Override
    public void beginContact(Contact contact) {
        Fixture fixtureA = contact.getFixtureA();
        Fixture fixtureB = contact.getFixtureB();
        int de = fixtureA.getFilterData().categoryBits + fixtureB.getFilterData().categoryBits;
        switch (de) {
            case FixtureDefType.PLAYER + FixtureDefType.GROUND:
                playScreen.playerSprite.isJump = false;
                playScreen.playerSprite.airJump = false;
                break;
        }

    }

    @Override
    public void endContact(Contact contact) {

    }

    @Override
    public void preSolve(Contact contact, Manifold oldManifold) {

    }

    @Override
    public void postSolve(Contact contact, ContactImpulse impulse) {

    }
}
